package org.kisekiproject.evaluator.nodes {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import org.kisekiproject.evaluator.Expression;
	import org.kisekiproject.evaluator.IExpression;
	import org.kisekiproject.evaluator.Token;
	import org.kisekiproject.evaluator.errors.ExpressionError;

	/**
	 * Token node.
	 */
	public class TokenNode extends EventDispatcher implements ISyntaxNode {
		private var _token:Token;
		private var _node:ISyntaxNode;
		private var _expression:String;

		/**
		 * Constructor.
		 */
		public function TokenNode(token:Token, node:ISyntaxNode, ex:String) {
			_token=token;
			_node=node;
			_expression=ex;
		}

		/**
		 * Get value.
		 */
		public function get value():Object {
			throw new ExpressionError("Unexpected "+_token.string,_expression,token.index);
		}

		/**
		 * Get index.
		 */
		public function get index():int {
			return _token.index;
		}

		/**
		 * Get token.
		 */
		public function get token():Token {
			return _token;
		}

		/**
		 * Get node.
		 */
		public function get node():ISyntaxNode {
			return _node;
		}
	}
}